// import { computed } from 'vue'
import { reactive,getCurrentInstance } from 'vue'
import { useAllDataStore }  from '@/stores'
import { useRouter } from 'vue-router'
export function useLogin() {

        const loginForm = reactive({
            username:'',
            password:''
          })
          // 
          const {proxy} = getCurrentInstance()
          const store = useAllDataStore()
          const router = useRouter()
          const handleLogin = async () => {
            const res = await proxy.$api.getMenu(loginForm)
            // 拿到菜单以后，在哪里显示
            store.updateMenuList(res.menuList)
            store.state.token = res.token
            store.addMenu(router)
            router.push('/home')
          }
    return {
        loginForm,handleLogin
    }
}